 #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
 #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
 
 CBUFFER_START(UnityPerMaterial)
    half4 _BaseColor;
    half4 _BaseMap_ST;
    half _BumpScale;
    half4 _SpecularColor;
    half4 _EmissionColor;
    half _Cutoff;
    half _SSS;
    half4 _Leaf;
 
CBUFFER_END


TEXTURE2D(_BaseMap);SAMPLER(sampler_BaseMap);
TEXTURE2D(_MetallicGlossMap);SAMPLER(sampler_MetallicGlossMap);
TEXTURE2D(_BumpMap);        SAMPLER(sampler_BumpMap);
struct LchSurfaceData
{
    half3 albedo;
 
    half  metallic;
    half  smoothness;
    half3 normalTS;
    half3 emission;
    half  occlusion;
    half  alpha;
    
};

 


#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl"
half Alpha(half albedoAlpha, half4 color, half cutoff)
{
#if !defined(_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A) && !defined(_GLOSSINESS_FROM_BASE_ALPHA)
    half alpha = albedoAlpha * color.a;
#else
    half alpha = color.a;
#endif

#if defined(_ALPHATEST_ON)
    clip(alpha - cutoff);
#endif

    return alpha;
}
half3 SampleNormal(float2 uv, TEXTURE2D_PARAM(bumpMap, sampler_bumpMap), half scale = half(1.0))
{
#ifdef _NORMALMAP
    half4 n = SAMPLE_TEXTURE2D(bumpMap, sampler_bumpMap, uv);
    #if BUMP_SCALE_NOT_SUPPORTED
        return UnpackNormal(n);
    #else
        return UnpackNormalScale(n, scale);
    #endif
#else
    return half3(0.0h, 0.0h, 1.0h);
#endif
}
            
half3 GetNormalST(float2 uv)
{
    #ifdef _NORMALMAP
    return SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale);
    #else
    return  half3(0,0,1);
    #endif
}

 
inline void InitializeLchSurfaceData(float2 uv,float4 vertexColor , out LchSurfaceData outSurfaceData)
{
    half4 albedoAlpha = SAMPLE_TEXTURE2D( _BaseMap, sampler_BaseMap,uv);
    outSurfaceData.alpha = Alpha(albedoAlpha.a, _BaseColor, _Cutoff);

 
    outSurfaceData.albedo = albedoAlpha.rgb * _BaseColor.rgb;
    outSurfaceData.metallic = 0;
    outSurfaceData.smoothness = 0;
    outSurfaceData.normalTS = GetNormalST(uv);
    outSurfaceData.occlusion = 1.0;
    outSurfaceData.emission = 1.0;

 

/*#if defined(_DETAIL)
    half detailMask = SAMPLE_TEXTURE2D(_DetailMask, sampler_DetailMask, uv).a;
    float2 detailUv = uv * _DetailAlbedoMap_ST.xy + _DetailAlbedoMap_ST.zw;
    outSurfaceData.albedo = ApplyDetailAlbedo(detailUv, outSurfaceData.albedo, detailMask);
    outSurfaceData.normalTS = ApplyDetailNormal(detailUv, outSurfaceData.normalTS, detailMask);
#endif*/
}
half4 SampleAlbedoAlpha(float2 uv, TEXTURE2D_PARAM(albedoAlphaMap, sampler_albedoAlphaMap))
{
    return half4(SAMPLE_TEXTURE2D(albedoAlphaMap, sampler_albedoAlphaMap, uv));
}
 